<?php

/**
 * Classe de création des ACL
 * */
class Cab_Acl_Acl extends Zend_Acl {

    public function __construct() {

        // CONTROLLERS
        $this->add(new Zend_Acl_Resource('index'));
        $this->add(new Zend_Acl_Resource('info'));
        $this->add(new Zend_Acl_Resource('login'));
        $this->add(new Zend_Acl_Resource('error'));
        $this->add(new Zend_Acl_Resource('mutuelle'));
        $this->add(new Zend_Acl_Resource('patient'));
        $this->add(new Zend_Acl_Resource('user'));
        $this->add(new Zend_Acl_Resource('prescripteur'));
        $this->add(new Zend_Acl_Resource('prescription'));
        $this->add(new Zend_Acl_Resource('acte'));
        $this->add(new Zend_Acl_Resource('planning'));

        // ROLES
        $this->addRole(new Zend_Acl_Role('guest'));
        $this->addRole(new Zend_Acl_Role('user'), 'guest');
        $this->addRole(new Zend_Acl_Role('admin'), 'user');
        $this->addRole(new Zend_Acl_Role('super'), 'admin');

        // GUEST
        $this->allow('guest', 'login', array('index', 'logout'));
        $this->allow('guest', 'info', array('about', 'contact'));

        // USER
        $this->allow('user', 'index', array('index', 'list'));
        $this->allow('user', 'prescripteur', array('index', 'edit'));
        $this->allow('user', 'prescription', array('index', 'edit'));
        $this->allow('user', 'user', array('index', 'edit', 'password'));
        $this->allow('user', 'mutuelle', array('index', 'edit'));
        $this->allow('user', 'patient', array('index', 'edit', 'autocomplete'));
        $this->allow('user', 'acte', array('index', 'edit'));
        $this->allow('user', 'planning', array('index', 'edit'));

        //ADMIN
        $this->allow('admin', 'user', array('add', 'edit'));
        $this->allow('admin', 'mutuelle', array('add', 'edit', 'delete'));
        $this->allow('admin', 'patient', array('add', 'edit', 'delete'));
        $this->allow('admin', 'prescripteur', array('add', 'delete'));
        $this->allow('admin', 'prescription', array('add', 'delete'));
        $this->allow('admin', 'acte', array('add', 'delete'));
    }

}